const cache = {
  state: {
    list: ["home", "orderDetail", "layout","commodityDetail","addressedi","address"],
    nav:[]
  },
  mutations: {
    ADD_NAV_NAME(state, name){
      state.nav.push(name)
    },
    DEL_NAV_NAME(state, index){
        state.nav.pop()
    },
    ADD_CACHE(state, data) {
      state.list.push(data)
    },
    ADD_CACHE_NA(state, name){
      
      state.list.push(name)
      
    },
    CLEAR_CACHE_INDEX: (state, index) => {
      if (index && state.list.length >= index) {
        state.list.splice(index, 1)
      }
    }
  },
  actions: {
    DEL_NAV({
      commit,
      state
    },info){
      commit("DEL_NAV_NAME",info)
    },
    ADD_NAV({
      commit,
      state
    },info){
      commit("ADD_NAV_NAME",info)
    },
    ADD_CACHE_NAME({ commit,
      state},info){
      commit("ADD_CACHE_NA",info)
    },
    DEL_CACHR_NAME({
      commit,
      state
    }, info) {
      let index=state.list.indexOf(info);
      commit("CLEAR_CACHE_INDEX",index)
    }
  }
}
export default cache;
